import axios from 'axios'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
 const requests =axios.create({
       baseURL:'http://localhost:3000',
       timeout:5000,
       withCredentials: true,//网易云输入这个可以在请求上加入cookie，保持登录状态

 })
 requests.interceptors.request.use((config)=>{
     //console.log(store);
     //添加临时请求头uuid----此请求头需要和后端沟通好
      NProgress.start()
     return config;
 }),
 requests.interceptors.response.use((res)=>{
       NProgress.done()
     return res.data;
 },(error)=>{
    NProgress.done()
    
    return Promise.reject(error)
     
 })
export default requests;